home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / fastkey.exe / FASTKEY.DOC < prev    next >
Encoding:
Text File  |  1992-12-11  |  14.7 KB  |  265 lines

  1.                           FastKey v1.1 for Turbo Pascal 6.0
  2.                                FastKey v1.0 for Turbo C
  3.                            Copyright 1992 by Steve Holley.
  4.  
  5.   Opening Rambling:
  6.        While writing my first arcade game for the IBM PC, I discovered that
  7.        the standard keyboard routines that I had available were not good
  8.        enough.  I needed a method to handle the key presses as soon as the
  9.        program was ready for them.  There was also a slight delay that
  10.        occurred when you switch between keys that you have been holding
  11.        down.  After much coding and research, I developed a routine that
  12.        would monitor the keyboard with enough speed to please me.  At the
  13.        suggestion of a good friend, and since I was unable to find a similar
  14.        product while developing my code (that would have saved me a lot of
  15.        time), I have decided to release a unit for Turbo Pascal 6.0 that
  16.        improves keyboard handling.  Special thanks to Curtis Keisler for the
  17.        conversion of the assembler code to a Turbo Pascal Unit and for his
  18.        suggestions.
  19.  
  20.   What FastKey is:
  21.        FastKey is an interrupt driven routine that monitors the keyboard,
  22.        keeping track of which keys are pressed and which are not.  At any
  23.        given time you can check to see which keys are pressed since the
  24.        interrupt occurs asynchronous to the rest of your program.  This may
  25.        sound strange but for arcade games it is a good way of handling the
  26.        keyboard.  It allows the program to process keyboard input as soon as
  27.        the program is ready for it.  I do not recommend this routine for
  28.        standard business applications since it does not buffer the input or
  29.        process the keyboard in the same way that the normal interrupt does. 
  30.        Also, any TSR (Terminate and Stay Resident) programs that use the
  31.        keyboard interrupt will not work with FastKey.  In general, as soon
  32.        as you install FastKey your program has the whole computer to itself. 
  33.        As soon as FastKey is removed, the TSRs will work properly.  While
  34.        FastKey is installed the following Turbo Pascal procedures and
  35.        functions should not be used: Readln, KeyPressed and ReadKey.  If you
  36.        attempt to uses these routines the computer may lock-up.  
  37.  
  38.   Disclaimer:
  39.        I wish that I did not have to include this section but due to the
  40.        highly "sue-able" state of the world, the following section is,
  41.        unfortunately, required.  FastKey is distributed "as is", with no
  42.        guarantee that it will work properly in any or all programs or
  43.        combinations of hardware.  The Author assumes no liability for any
  44.        damages, financial, software or hardware, caused by the use, misuse,
  45.        or modification of this product, nor is he liable if part of a
  46.        passing 747 falls on your house destroying your computer while using
  47.        this product.
  48.  
  49.   Distribution:
  50.        You may freely distribute unmodified copies of the FastKey package
  51.        (all files listed in the README file) so long as any fee charged is
  52.        for distribution costs only.  Commercial distribution strictly
  53.        prohibited.
  54.  
  55.   System Requirements:
  56.        1. IBM PC/XT/AT/Jr/PS/2 or 100%
  57.        2. Turbo Pascal(tm) v6.0 or greater
  58.  
  59.   Turbo Pascal and Turbo C are registered trademarks of BORLAND International.
  60.   Compuserve is a registered trademark of Compuserve Incorporated.   Usage:
  61.        FastKey is easy to use.  To make it available to your program just
  62.        include FastKey in your Uses section at the start of your program. 
  63.        See the Turbo Pascal reference manual for help with the Uses command. 
  64.        Only four routines are used in the FastKey unit.  Each is detailed
  65.        below.  For an example of how to use FastKey, examine DEMO2.PAS.
  66.  
  67.        Procedure InstallFastKey;
  68.        Function  FastKeyInstalled : Boolean;
  69.        Function  Pressed (KeyCode : Byte) : Boolean;
  70.        Function  FastKeyPressed : Boolean;
  71.        Procedure UnInstallFastKey;
  72.  
  73.        InstallFastKey
  74.        Before FastKey can be used, it must first be installed.  At the start
  75.        of your program, call InstallFastKey.  I recommend that you do this
  76.        in your main program block or in your initialization routine.  That's
  77.        all there is to the installation.  As soon as it is installed you can
  78.        begin to use Pressed to determine which keys are pressed. 
  79.  
  80.        FastKeyInstalled
  81.        The function FastKeyInstalled is used to determine if FastKey has
  82.        been installed.  It will return true if FastKey has been installed. 
  83.        You probably will not use it but it is there if you need it.
  84.  
  85.        Pressed(KeyCode)
  86.        Pressed will return a boolean value indicating the status of any key
  87.        on the keyboard.  See Key Code Table at the end of this document for
  88.        a list of each of the keys and their key code.  A value of TRUE
  89.        indicates that the key is pressed.  A value of FALSE means it is not. 
  90.        Note that any combination of keys may be checked by successive calls
  91.        to pressed.  For example to determine if both Cursor Up and Cursor
  92.        Left are pressed use the following line:
  93.  
  94.             IF Pressed(FKUP) AND Pressed(FKLEFT) THEN some action
  95.  
  96.        Several useful key combinations are possible by combining boolean
  97.        expressions with Pressed.  It is also possible to check that a key is
  98.        not pressed at the same time as another key is pressed.  If the
  99.        cursor left and right controlled a ships movement on screen, you
  100.        would not want to be able to move if both keys were pressed.  The
  101.        following lines move the ship and insure that only legal key
  102.        combinations are allowed.
  103.  
  104.             IF Pressed(FKLEFT) AND NOT Pressed(FKRIGHT) THEN move left
  105.             IF Pressed(FKRIGHT) AND NOT Pressed(FKLEFT) THEN move right
  106.  
  107.        FastKeyPressed
  108.        The function FastKeyPressed is used to see if any key is currently
  109.        pressed, perhaps to see if there is a need to check for an complex
  110.        key combination.  It is used exactly the same as the Turbo Pascal
  111.        function Keypressed.
  112.  
  113.        UnInstallFastKey
  114.        It is very important that you remove FastKey from the interrupt table
  115.        before you exit your program.  Failure to do so will result in your
  116.        computer locking up so tightly that you will have to use the big red
  117.        button to bring it back to life.  This should be one of the last
  118.        instructions executed, perhaps in the main program block or a routine
  119.        that resets the computer.   Registration:
  120.        FastKey is distributed as shareware.  The registration fee for
  121.        continued use of the unit is proper credit.  If you use these
  122.        routines in a program, please include something like "FASTKEY
  123.        Keyboard Routines by Steve Holley" in the title screen or
  124.        documentation, and just drop me a note at the following address.  I'd
  125.        like to see what people have been able to do with these routines.  If
  126.        you would like to make a contribution to the author for the use of
  127.        the unit, any amount will be accepted (and is encouraged if you
  128.        charge a fee for your software that uses FastKey.  You decide what is
  129.        fair since only you know how important these routines were to your
  130.        program.).
  131.  
  132.        All source code is available for $20.00.  This includes the original
  133.        .ASM file, an .OBJ file compiled with Borland TASM 2.0 (the best
  134.        assembler on the market), the source code for the Turbo Pascal Unit
  135.        that you already have and the C source code for FastKey, and the
  136.        source & executable for a program to display the key codes generated
  137.        by the keyboard.  All source code is heavily commented to make
  138.        modification and understanding easier.  The source code will come in
  139.        handy if/when TP 7.0 comes out and the unit formats are again
  140.        changed, or you want to add support for a new or non-standard
  141.        keyboard.  With the assembler source code it should be possible to
  142.        add these routines to any programming language.  To receive the
  143.        source, send a check for $20.00 made payable to Steve Holley to:
  144.  
  145.             Steve Holley
  146.             Rt. 1 Box 210-W-1
  147.             Barnwell, SC 29812.  
  148.  
  149.        Please specify the disk size that you would like and allow 2-4 weeks
  150.        for delivery.
  151.  
  152.   Contacting me:
  153.        I may be reached at the above address for questions or comments about
  154.        FastKey.  I also visit the Gamers forum on Compuserve(tm) frequently. 
  155.        Leave mail for 76424,1521.  This is the fastest way to reach me if
  156.        you have any trouble using FastKey or have any questions about it.                                   Key Code Listing
  157.  
  158.           Key________     Code_________       Key________     Code_________
  159.           Esc             FKEsc               CapsLock        FKCapsLock
  160.           F1              FKF1                A               FKA
  161.           F2              FKF2                S               FKS
  162.           F3              FKF3                D               FKD
  163.           F4              FKF4                F               FKF
  164.           F5              FKF5                G               FKG
  165.           F6              FKF6                H               FKH
  166.           F7              FKF7                J               FKJ
  167.           F8              FKF8                K               FKK
  168.           F9              FKF9                L               FKL
  169.           F10             FKF10               ;               FKSemiColon
  170.           F11             FKF11               '               FKRQuote
  171.           F12             FKF12               Enter           FKEnter
  172.           Print Screen    FKPrtSc
  173.           Scroll Lock     FKScrollLock        Left Shift      FKLShift
  174.                                               Z               FKZ
  175.           `               FKLQuote            X               FKX
  176.           1               FK1                 C               FKC
  177.           2               FK2                 V               FKV
  178.           3               FK3                 B               FKB
  179.           4               FK4                 N               FKN
  180.           5               FK5                 M               FKM
  181.           6               FK6                 ,               FKComma
  182.           7               FK7                 .               FKPeriod
  183.           8               FK8                 /               FKFSlash
  184.           9               FK9                 Right Shift   FLRShift
  185.           0               FK0
  186.           -               FKMinus             Ctrl            FKCtrl
  187.           =               FKEqual             Alt             FKAlt
  188.           Back Space      FKBkSp              Space           FKSpace
  189.  
  190.           Tab             FKTab
  191.           Q               FKQ                 NUMERIC KEYPAD
  192.           W               FKW
  193.           E               FKE                 FKNumLock
  194.           R               FKR                 FKKP7   FKKP8   FKKP9  FKKPMinus
  195.           T               FKT                 FKKP4   FKKP5   FKKP6  FKKPPlus
  196.           Y               FKY                 FKKP1   FKKP2   FKKP3
  197.           U               FKU                 FKKP0   FKKPPeriod
  198.           I               FKI
  199.           O               FKO                 CURSOR CONTROL
  200.           P               FKP
  201.           [               FKLBracket          FKUpLeft   FKUp      FKUpRight
  202.           ]               FKRBracket          FKLeft     FKCenter  FKRight
  203.           \               FKBSlash            FKDownLeft FKDown    FKDownRight
  204.  
  205.  
  206.   Notes about the Key Code Table:
  207.        The naming convention for the key codes is as follows:  FK + Key
  208.        Name.  For example, the key code for the left bracket is FKLBracket
  209.        (FK for FastKey, L for Left, and then Bracket).
  210.  
  211.        It is not necessary to have a key code for all the labels on the
  212.        keyboard.  Keys that have multiple labels are identified by the
  213.        primary label for that key.  If you want to explicitly check for one
  214.        of these labels you will have to check the Shift, Ctrl, and Alt        status yourself.  See the description of Pressed above for an example
  215.        of detecting multiple keys pressed.
  216.  
  217.        Due to the way some keyboards are designed, different keys may create
  218.        the same key codes.  On the AT Keyboard with 101 keys both Cursor Up
  219.        and 8 on the numeric keypad generate the same key code while the
  220.        number 8 above the alphabetic keys does not create the same key code
  221.        as the 8 on the keypad.
  222.          ----------------end-of-author's-documentation---------------
  223.  
  224.                          Software Library Information:
  225.  
  226.                     This disk copy provided as a service of
  227.  
  228.                            Public (software) Library
  229.  
  230.          We are not the authors of this program, nor are we associated
  231.          with the author in any way other than as a distributor of the
  232.          program in accordance with the author's terms of distribution.
  233.  
  234.          Please direct shareware payments and specific questions about
  235.          this program to the author of the program, whose name appears
  236.          elsewhere in  this documentation. If you have trouble getting
  237.          in touch with the author,  we will do whatever we can to help
  238.          you with your questions. All programs have been tested and do
  239.          run.  To report problems,  please use the form that is in the
  240.          file PROBLEM.DOC on many of our disks or in other written for-
  241.          mat with screen printouts, if possible.  PsL cannot debug pro-
  242.          programs over the telephone, though we can answer questions.
  243.  
  244.          Disks in the PsL are updated  monthly,  so if you did not get
  245.          this disk directly from the PsL, you should be aware that the
  246.          files in this set may no longer be the current versions. Also,
  247.          if you got this disk from another vendor and are having prob-
  248.          lems,  be aware that  some files may have become corrupted or
  249.          lost by that vendor. Get a current, working disk from PsL.
  250.  
  251.          For a copy of the latest monthly software library newsletter
  252.          and a list of the 4,000+ disks in the library, call or write
  253.  
  254.                            Public (software) Library
  255.                                  P.O.Box 35705
  256.                             Houston, TX 77235-5705
  257.  
  258.                                  Orders only:
  259.                                 1-800-2424-PSL
  260.                               MC/Visa/AmEx/Discover
  261.  
  262.                           Outside of U.S. or in Texas
  263.                           or for general information,
  264.                               Call 1-713-524-6394                 
  265.